package com.study.demo.concurrent;

import java.util.concurrent.Callable;

/**
 * Created by ahdkk on 2016/1/12.
 */
public class SumCalculator implements Callable<Long>{
    private int[] numbers;

    private int start;

    private int end;

    public SumCalculator(final int[] numbers, int start, int end) {
        this.numbers = numbers;
        this.start = start;
        this.end = end;
    }

    @Override
    public Long call() throws Exception {
        Long sum = 0L;
        for (int i = start; i < end; i++) {
            sum += numbers[i];
        }
        return sum;
    }
}
